package com.biz.primus.model.cart.vo;

import com.biz.primus.model.cart.enums.ShippingLevel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * 购物车明细vo
 *
 * @author lei
 * @date 2017/01/12
 */
@Getter
@Setter
@ApiModel("购物车明细对象VO")
public class ShopCartItemVo implements Comparable<ShopCartItemVo>, Serializable {

    private static final long serialVersionUID = 7026730374601206229L;
    /**
     * 商品名称
     */
    @ApiModelProperty("商品信息")
    private String name;

    /**
     * 商品子标题
     */
    @ApiModelProperty("商品子标题")
    private String subTitle;

    /**
     * 商品编码
     */
    @ApiModelProperty("商品编码")
    private String productCode;

    /**
     * 商品图片
     */
    @ApiModelProperty("商品图片")
    private String logo;

    /**
     * 价格
     */
    @ApiModelProperty("市场价")
    private Integer marketPrice;

    /**
     * 价格
     */
    @ApiModelProperty("商品单价")
    private Integer price;

    /**
     * 购物车数量
     */
    @ApiModelProperty("数量")
    private Integer amount;


    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    private Timestamp createTime;

    /**
     * 最后更新时间
     */
    @ApiModelProperty("最后更新时间")
    private Timestamp updateTime;

    /**
     * 是否选中
     */
    @ApiModelProperty("选中状态")
    private boolean selected = false;

    /**
     * 是否可买
     */
    @ApiModelProperty("是否可买")
    private boolean canBuy = true;

    /**
     * 配送等级
     */
    @ApiModelProperty("配送等级")
    private ShippingLevel shippingLevel = ShippingLevel.SHIPPING_DEFAULT;

    /**
     * 消息
     */
    @ApiModelProperty("消息")
    private String message = "";


    @Override
    public int compareTo(ShopCartItemVo o) {
        return o.getUpdateTime().compareTo(this.getUpdateTime());
    }

    public Integer totalPrice() {
        return price == null ? 0 : amount == null ? 0 : price * amount;
    }
}
